package com.globallogic.restdemo.dto;

import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement
@XmlType(propOrder = { "id", "email", "firstName", "lastName" })
@Data
public class User {

    private Long id;

    @NotNull(message = "email cannot be null")
    @Email(message = "it is not an email")
    private String email;

    @NotNull(message = "first name cannot be null")
    @Length(max = 50)
    private String firstName;

    @NotNull(message = "last name cannot be null")
    @Length(max = 50)
    private String lastName;

    public User() {}

    public User(String email, String firstName, String lastName) {
        this.email = email;
        this.firstName = firstName;
        this.lastName = lastName;
    }
}
